<?php


/**
 * Base class that represents a query for the 'user_roles' table.
 *
 *
 *
 * @method EmpevalUserRolesQuery orderById($order = Criteria::ASC) Order by the id column
 * @method EmpevalUserRolesQuery orderByFormUserId($order = Criteria::ASC) Order by the form_user_id column
 * @method EmpevalUserRolesQuery orderByToUserId($order = Criteria::ASC) Order by the to_user_id column
 * @method EmpevalUserRolesQuery orderByRoleId($order = Criteria::ASC) Order by the role_id column
 * @method EmpevalUserRolesQuery orderByCreated($order = Criteria::ASC) Order by the created column
 *
 * @method EmpevalUserRolesQuery groupById() Group by the id column
 * @method EmpevalUserRolesQuery groupByFormUserId() Group by the form_user_id column
 * @method EmpevalUserRolesQuery groupByToUserId() Group by the to_user_id column
 * @method EmpevalUserRolesQuery groupByRoleId() Group by the role_id column
 * @method EmpevalUserRolesQuery groupByCreated() Group by the created column
 *
 * @method EmpevalUserRolesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method EmpevalUserRolesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method EmpevalUserRolesQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method EmpevalUserRolesQuery leftJoinRoles($relationAlias = null) Adds a LEFT JOIN clause to the query using the Roles relation
 * @method EmpevalUserRolesQuery rightJoinRoles($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Roles relation
 * @method EmpevalUserRolesQuery innerJoinRoles($relationAlias = null) Adds a INNER JOIN clause to the query using the Roles relation
 *
 * @method EmpevalUserRolesQuery leftJoinUsersRelatedByFormUserId($relationAlias = null) Adds a LEFT JOIN clause to the query using the UsersRelatedByFormUserId relation
 * @method EmpevalUserRolesQuery rightJoinUsersRelatedByFormUserId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the UsersRelatedByFormUserId relation
 * @method EmpevalUserRolesQuery innerJoinUsersRelatedByFormUserId($relationAlias = null) Adds a INNER JOIN clause to the query using the UsersRelatedByFormUserId relation
 *
 * @method EmpevalUserRolesQuery leftJoinUsersRelatedByToUserId($relationAlias = null) Adds a LEFT JOIN clause to the query using the UsersRelatedByToUserId relation
 * @method EmpevalUserRolesQuery rightJoinUsersRelatedByToUserId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the UsersRelatedByToUserId relation
 * @method EmpevalUserRolesQuery innerJoinUsersRelatedByToUserId($relationAlias = null) Adds a INNER JOIN clause to the query using the UsersRelatedByToUserId relation
 *
 * @method EmpevalUserRoles findOne(PropelPDO $con = null) Return the first EmpevalUserRoles matching the query
 * @method EmpevalUserRoles findOneOrCreate(PropelPDO $con = null) Return the first EmpevalUserRoles matching the query, or a new EmpevalUserRoles object populated from the query conditions when no match is found
 *
 * @method EmpevalUserRoles findOneById(int $id) Return the first EmpevalUserRoles filtered by the id column
 * @method EmpevalUserRoles findOneByFormUserId(int $form_user_id) Return the first EmpevalUserRoles filtered by the form_user_id column
 * @method EmpevalUserRoles findOneByToUserId(int $to_user_id) Return the first EmpevalUserRoles filtered by the to_user_id column
 * @method EmpevalUserRoles findOneByRoleId(int $role_id) Return the first EmpevalUserRoles filtered by the role_id column
 * @method EmpevalUserRoles findOneByCreated(string $created) Return the first EmpevalUserRoles filtered by the created column
 *
 * @method array findById(int $id) Return EmpevalUserRoles objects filtered by the id column
 * @method array findByFormUserId(int $form_user_id) Return EmpevalUserRoles objects filtered by the form_user_id column
 * @method array findByToUserId(int $to_user_id) Return EmpevalUserRoles objects filtered by the to_user_id column
 * @method array findByRoleId(int $role_id) Return EmpevalUserRoles objects filtered by the role_id column
 * @method array findByCreated(string $created) Return EmpevalUserRoles objects filtered by the created column
 *
 * @package    propel.generator.empeval.om
 */
abstract class EmpevalBaseUserRolesQuery extends ModelCriteria
{
    /**
     * Initializes internal state of EmpevalBaseUserRolesQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_empeval', $modelName = 'EmpevalUserRoles', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new EmpevalUserRolesQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     EmpevalUserRolesQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return EmpevalUserRolesQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof EmpevalUserRolesQuery) {
            return $criteria;
        }
        $query = new EmpevalUserRolesQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   EmpevalUserRoles|EmpevalUserRoles[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = EmpevalUserRolesPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(EmpevalUserRolesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   EmpevalUserRoles A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, FORM_USER_ID, TO_USER_ID, ROLE_ID, CREATED FROM user_roles WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new EmpevalUserRoles();
            $obj->hydrate($row);
            EmpevalUserRolesPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return EmpevalUserRoles|EmpevalUserRoles[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|EmpevalUserRoles[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(EmpevalUserRolesPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(EmpevalUserRolesPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(EmpevalUserRolesPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the form_user_id column
     *
     * Example usage:
     * <code>
     * $query->filterByFormUserId(1234); // WHERE form_user_id = 1234
     * $query->filterByFormUserId(array(12, 34)); // WHERE form_user_id IN (12, 34)
     * $query->filterByFormUserId(array('min' => 12)); // WHERE form_user_id > 12
     * </code>
     *
     * @see       filterByUsersRelatedByFormUserId()
     *
     * @param     mixed $formUserId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function filterByFormUserId($formUserId = null, $comparison = null)
    {
        if (is_array($formUserId)) {
            $useMinMax = false;
            if (isset($formUserId['min'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::FORM_USER_ID, $formUserId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($formUserId['max'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::FORM_USER_ID, $formUserId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserRolesPeer::FORM_USER_ID, $formUserId, $comparison);
    }

    /**
     * Filter the query on the to_user_id column
     *
     * Example usage:
     * <code>
     * $query->filterByToUserId(1234); // WHERE to_user_id = 1234
     * $query->filterByToUserId(array(12, 34)); // WHERE to_user_id IN (12, 34)
     * $query->filterByToUserId(array('min' => 12)); // WHERE to_user_id > 12
     * </code>
     *
     * @see       filterByUsersRelatedByToUserId()
     *
     * @param     mixed $toUserId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function filterByToUserId($toUserId = null, $comparison = null)
    {
        if (is_array($toUserId)) {
            $useMinMax = false;
            if (isset($toUserId['min'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::TO_USER_ID, $toUserId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($toUserId['max'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::TO_USER_ID, $toUserId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserRolesPeer::TO_USER_ID, $toUserId, $comparison);
    }

    /**
     * Filter the query on the role_id column
     *
     * Example usage:
     * <code>
     * $query->filterByRoleId(1234); // WHERE role_id = 1234
     * $query->filterByRoleId(array(12, 34)); // WHERE role_id IN (12, 34)
     * $query->filterByRoleId(array('min' => 12)); // WHERE role_id > 12
     * </code>
     *
     * @see       filterByRoles()
     *
     * @param     mixed $roleId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function filterByRoleId($roleId = null, $comparison = null)
    {
        if (is_array($roleId)) {
            $useMinMax = false;
            if (isset($roleId['min'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::ROLE_ID, $roleId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($roleId['max'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::ROLE_ID, $roleId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserRolesPeer::ROLE_ID, $roleId, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(EmpevalUserRolesPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserRolesPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query by a related EmpevalRoles object
     *
     * @param   EmpevalRoles|PropelObjectCollection $roles The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserRolesQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByRoles($roles, $comparison = null)
    {
        if ($roles instanceof EmpevalRoles) {
            return $this
                ->addUsingAlias(EmpevalUserRolesPeer::ROLE_ID, $roles->getId(), $comparison);
        } elseif ($roles instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalUserRolesPeer::ROLE_ID, $roles->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByRoles() only accepts arguments of type EmpevalRoles or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Roles relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function joinRoles($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Roles');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Roles');
        }

        return $this;
    }

    /**
     * Use the Roles relation Roles object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalRolesQuery A secondary query class using the current class as primary query
     */
    public function useRolesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinRoles($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Roles', 'EmpevalRolesQuery');
    }

    /**
     * Filter the query by a related EmpevalUsers object
     *
     * @param   EmpevalUsers|PropelObjectCollection $users The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserRolesQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUsersRelatedByFormUserId($users, $comparison = null)
    {
        if ($users instanceof EmpevalUsers) {
            return $this
                ->addUsingAlias(EmpevalUserRolesPeer::FORM_USER_ID, $users->getId(), $comparison);
        } elseif ($users instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalUserRolesPeer::FORM_USER_ID, $users->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByUsersRelatedByFormUserId() only accepts arguments of type EmpevalUsers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the UsersRelatedByFormUserId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function joinUsersRelatedByFormUserId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('UsersRelatedByFormUserId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'UsersRelatedByFormUserId');
        }

        return $this;
    }

    /**
     * Use the UsersRelatedByFormUserId relation Users object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalUsersQuery A secondary query class using the current class as primary query
     */
    public function useUsersRelatedByFormUserIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinUsersRelatedByFormUserId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'UsersRelatedByFormUserId', 'EmpevalUsersQuery');
    }

    /**
     * Filter the query by a related EmpevalUsers object
     *
     * @param   EmpevalUsers|PropelObjectCollection $users The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserRolesQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUsersRelatedByToUserId($users, $comparison = null)
    {
        if ($users instanceof EmpevalUsers) {
            return $this
                ->addUsingAlias(EmpevalUserRolesPeer::TO_USER_ID, $users->getId(), $comparison);
        } elseif ($users instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalUserRolesPeer::TO_USER_ID, $users->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByUsersRelatedByToUserId() only accepts arguments of type EmpevalUsers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the UsersRelatedByToUserId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function joinUsersRelatedByToUserId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('UsersRelatedByToUserId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'UsersRelatedByToUserId');
        }

        return $this;
    }

    /**
     * Use the UsersRelatedByToUserId relation Users object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalUsersQuery A secondary query class using the current class as primary query
     */
    public function useUsersRelatedByToUserIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUsersRelatedByToUserId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'UsersRelatedByToUserId', 'EmpevalUsersQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   EmpevalUserRoles $userRoles Object to remove from the list of results
     *
     * @return EmpevalUserRolesQuery The current query, for fluid interface
     */
    public function prune($userRoles = null)
    {
        if ($userRoles) {
            $this->addUsingAlias(EmpevalUserRolesPeer::ID, $userRoles->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
